const HtmlWebpackPlugin = require("html-webpack-plugin");
const webpack = require("webpack");

module.exports = {
  mode: "development",
  devtool: "source-map",
  output: {
    filename: "[name].[chunkhash:5].js",
  },
  plugins: [
    new HtmlWebpackPlugin({
      temp: "./public/index.html",
    }),
    new webpack.DefinePlugin({
      PI: `Math.PI`, // PI = Math.PI
      VERSION: `"1.0.0"`, // VERSION = "1.0.0"
      DOMAIN: JSON.stringify("duyi.com"),
    }),
    new webpack.BannerPlugin({
      banner: `
      hash:[hash]
      chunkhash:[chunkhash]
      name:[name]
      author:yuanjin
      corporation:duyi
      `,
    }),
    new webpack.ProvidePlugin({
      $: "jquery",
      _: "lodash",
    }),
  ],
  devServer: {
    port: 8888,
    open: true,
  },
};
